package com.study.iterator.course;

public class Test {
    public static void main(String[] args) {
        Course java = new Course("架构");
        Course base = new Course("java基础");
        Course design = new Course("设计模式");
        Course ai = new Course("人工智能");

        ICourseAggregate aggregate = new CourseAggregateImpl();
        aggregate.add(java);
        aggregate.add(base);
        aggregate.add(design);
        aggregate.add(ai);

        Iterator<Course> iterator = aggregate.iterator();
        while (iterator.hashNext()){
            Course course = iterator.next();
            System.out.println(course.getName());
        }

        System.out.println("--------------删除元素------------------");
        aggregate.remove(base);
        Iterator<Course> iterator2 = aggregate.iterator();
        while (iterator2.hashNext()){
            Course course = iterator2.next();
            System.out.println(course.getName());
        }
    }
}
